﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Jbe.Composite.Extensions;
using Jbe.TestSuite.Help.Applications;

namespace Jbe.TestSuite.Help.Presentation
{
    /// <summary>
    /// Interaction logic for HelpView.xaml
    /// </summary>
    public partial class HelpView : UserControl, IHelpView
    {
        private DelegateCommand browseBackCommand;
        private DelegateCommand browseForwardCommand;


        public HelpView()
        {
            InitializeComponent();
            webBrowser.WebBrowser.Navigated += new NavigatedEventHandler(WebBrowserNavigated);
            browseBackCommand = new DelegateCommand(BrowseBack, CanBrowseBack);
            browseBackButton.Command = browseBackCommand;
            browseForwardCommand = new DelegateCommand(BrowseForward, CanBrowseForward);
            browseForwardButton.Command = browseForwardCommand;
        }


        private bool CanBrowseBack()
        {
            return webBrowser.WebBrowser.CanGoBack;
        }

        private bool CanBrowseForward()
        {
            return webBrowser.WebBrowser.CanGoForward;
        }

        private void BrowseBack()
        {
            webBrowser.WebBrowser.GoBack();
        }

        private void BrowseForward()
        {
            webBrowser.WebBrowser.GoForward();
        }

        private void WebBrowserNavigated(object sender, NavigationEventArgs e)
        {
            browseBackCommand.RaiseCanExecuteChanged();
            browseForwardCommand.RaiseCanExecuteChanged();
        }
    }
}
